﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentValidation;
using Microhard.Protal.Models;

namespace Microhard.Protal.Validators
{
    public class ProductModelValidator : AbstractValidator<ProductModel>
    {
        public ProductModelValidator()
        {
            RuleSet("Insert", () =>
            {
                RuleFor(u => u.Name).NotEmpty().WithMessage("请填写产品名称").When(r => r.CategoryID == Guid.Empty);
                RuleFor(u => u.Name).NotEmpty().WithMessage("请填写描述").When(r => r.CategoryID == Guid.Empty);
            });


            RuleSet("Update", () =>
            {
                RuleFor(u => u.Name).NotEmpty().WithMessage("请填写产品名称");
                RuleFor(u => u.Name).NotEmpty().WithMessage("请填写描述").When(r => r.CategoryID == Guid.Empty);
            });

            RuleSet("Delete", () =>
            {

            });
        }
    }
}
